<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>首页</title>
  <link rel="icon" href="image/网页图标.png" type="image/x-icon">

  <script src="http://47.106.66.89:8080/js/vue.min.js"></script>
  <script src="http://47.106.66.89:8080/js/axios.min.js"></script>
  <link  href="http://47.106.66.89:8080/js/ele-2.15.7/theme-chalk/index.css" rel="stylesheet">
  <script src="http://47.106.66.89:8080/js/ele-2.15.7/index.js"></script>
  <script src="js/rankingq.js"></script>
  <script src="js/rankingp.js"></script>
  <script src="js/top.js"></script>
  <script src="js/echarts.js"></script>

  <style>
    *{
		padding: 0;
        margin: 0;
	}
	html, body, #app {
		width: 100%;
		height: 100%;
		font-size: 14px;
	}
	.el-container{
		width: 100%;
		height: 100%;
	}
	.el-header{
		width: 100%;
		padding: 0%;
	}

    /* 走马灯 */
    .el-carousel__item h3 {
    color: #475669;
    font-size: 18px;
    opacity: 0.75;
    line-height: 300px;
    margin: 0;
  }
  
  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }
  
  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
  
  /* 卡片 */
  .c1{
    width: 100%;
    height: 100%;
    font-size: 35px;
  }

  .d4{
    position: relative;
  }

  /* 弹出 */
  .d1{
    width: 200px;
    height: 400px;
    position: absolute;
    z-index: 100;
    left: 10%;
  }
  .d2{
    width: 500px;
    height: 400px;
    position: absolute;
    z-index: 100;
    left: 21%;
    background-color: #e6e9ec;
  }
  .c2{
    width: 100%;
    height: 100px;
    background-color: #f3f5f8;
  }
  .c2:hover{
    background-color: #dde4ed;
  }

  /* 浮动 */
  .f{
    float: left;
  }

  .d3{
    width: 100%;
    height: 800px;
  }

  .d5{
    width: 50%;
    height: 500px;
  }

  .d6{
    width: 40%;
    height: 499px;
    margin-right: 80px;
    position: relative;
    left: 50px;
  }
  .i1{
    position: relative;
    top: -15px;
  }

  .p1{
    margin: 8px 10px 0 10px;
    text-decoration: none;
      color: #333333;
  }

  /* 外用 */
  .flex{
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 100%;
        gap: 10px;
    }
    .flex>*{
        margin: 0px;
        padding: 0px;
    }
    .hsc:hover{
        transform: scale(1.1);
        box-shadow: 3px 3px 3px 3px #8888;
    }

    .item{
      width: 210px;
    height: 160px;
    text-align: center;
    flex-direction: column;
    border-radius: 16px;
    border: 3px solid #fff;
    background: linear-gradient(180deg, #f6f9ff, #fff);
    box-shadow: 0 24px 24px rgba(214, 218, 227, .3);
    top: 0;
    transition: all .3s;
    transition-delay: 0s;
    cursor: pointer;
    }
    .itembox{
      display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    grid-gap: 40px 120px;
    gap: 40px 80px;
    }

    /* 主页快捷显示信息 */
    .i2{
      margin: 10px;
    }
    .p2{
      font-size: 18px;
      margin: 18px 0 0 5px;
    }
    .a1{
      margin: 0 10px 0 10px;
      text-decoration: none;
      color: #475669;
    }
    .a2{
      width: 20%;
      height: 20%;
      display: flex; /* 设置为Flex布局 */  
      align-items: center; /* 垂直居中 */  
      justify-content: center; /* 可选，用于水平居中 */
      background-color: #f9fafb;
      text-decoration: none;
      color: #475669;
      float: left;
    }
    .user{
      float: right;
      position: relative;
      left: -40px;
      top: 15px;
    }
    .d7{
        margin-top: 1%;
        width: 100%;
        height: 30%;
    }
    .c6{
        position: relative;
        top: 20px;
        width: 100%;
        height: 100%;
    }
  </style>
</head>

<body>
    <div id="app">
        <el-container>
            <!-- 头部 -->
            <el-header height="12%">
                <top @getuser="user">
                </top>
            </el-header>
            <!-- 身体 -->
            <el-main>
                <!-- 走马灯与弹出 -->
                <div class="d4">
                    <!-- 弹出 -->
                    <div class="d1">
                        <div class="c2" @mouseenter="type(1)">
                          <img src="image/Java.png" class="f i2">
                          <p class="f p2">JAVA开发</p>
                          <br/><br/><br/>
                          <a href="typequestion.html?id=9" class="f a1">HTML</a>
                          <a href="typequestion.html?id=8" class="f a1">Java基础</a>
                        </div>

                        <div class="c2" @mouseenter="type(2)">
                          <img src="image/数据库.png" class="f i2">
                          <p class="f p2">数据库</p>
                          <br/><br/><br/>
                          <a href="typequestion.html?id=21" class="f a1">mysql</a>
                          <a href="typequestion.html?id=25" class="f a1">redis</a>
                        </div>

                        <div class="c2" @mouseenter="type(3)">
                          <img src="image/学生.png" class="f i2">
                          <p class="f p2">学生题库</p>
                          <br/><br/><br/>
                          <a href="typequestion.html?id=28" class="f a1">初中</a>
                          <a href="typequestion.html?id=29" class="f a1">高中</a>
                        </div>

                        <div class="c2" @mouseenter="type(4)">
                          <img src="image/学前教育.png" class="f i2">
                          <p class="f p2">学前教育</p>
                          <br/><br/><br/>
                          <a href="typequestion.html?id=30" class="f a1">识字</a>
                          <a href="typequestion.html?id=31" class="f a1">识动物</a>
                        </div></div>

                    <div class="d2" v-if="typenum === 1">
                      <a class="a2" href="typequestion.html?id=8">Java</a>
                      <a class="a2" href="typequestion.html?id=9">HTML</a>
                      <a class="a2" href="typequestion.html?id=10">JS</a>
                      <a class="a2" href="typequestion.html?id=11">CSS</a>
                      <a class="a2" href="typequestion.html?id=12">Spring</a>
                      <a class="a2" href="typequestion.html?id=15">Spring MVC</a>
                      <a class="a2" href="typequestion.html?id=32">Spring Boot</a>
                      <a class="a2" href="typequestion.html?id=18">Spring Cloud</a>
                    </div>
                    <div class="d2" v-else-if="typenum === 2">
                      <a class="a2" href="typequestion.html?id=21">Mysql</a>
                      <a class="a2" href="typequestion.html?id=23">Oracle</a>
                      <a class="a2" href="typequestion.html?id=25">Redis</a>
                    </div>
                    <div class="d2" v-else-if="typenum === 3">
                      <a class="a2" href="typequestion.html?id=27">小学</a>
                      <a class="a2" href="typequestion.html?id=28">初中</a>
                      <a class="a2" href="typequestion.html?id=29">高中</a>
                    </div>
                    <div class="d2" v-else-if="typenum === 4">
                      <a class="a2" href="typequestion.html?id=30">识字</a>
                      <a class="a2" href="typequestion.html?id=31">识动物</a>
                    </div>
                    <!-- 走马灯 -->
                    <div @mouseenter="type(0)">
                        <el-carousel indicator-position="outside" height="400px">
                            <el-carousel-item v-for="(image, index) in images"  
                            :key="index">
                            <img :src="image" alt="carousel image" style="width: 100%; height: 100%; object-fit: cover;">
                            </el-carousel-item>
                          </el-carousel>
                    </div>
                </div>
                <!-- 解释网站 -->
                 <div class="d3">
                    <div class="d5 f itembox">
                      <div class="item f"><img src="https://up.zaixiankaoshi.com/FuMDizyCg9Z1-h5UDwvup_TqPbsk" alt=""> <p>顺序练习</p></div>
                      <div class="item f"><img src="https://up.zaixiankaoshi.com/FtCAIUlmuVs0r8e9eeoItd8kypni" alt=""> <p>随机练习</p></div>
                      <div class="item f"><img src="https://up.zaixiankaoshi.com/FoY2KkXlW8UyVpv8hHYHc9t8B8H4" alt=""> <p>模拟考试</p></div>
                      <div class="item f"><img src="https://up.zaixiankaoshi.com/Fry6Sxg68jejAffvZvGA8T3JuA7r" alt=""> <p>题型练习</p></div>
                      <div class="item f"><img src="https://up.zaixiankaoshi.com/Foy2MqITlIHj6FuCEtlo_4KHz2aI" alt=""> <p>高频考题</p></div>
                      <div class="item f"><img src="https://up.zaixiankaoshi.com/Fh5XV6GAQahvklVxFDg0O6N1qNP_" alt=""> <p>错题/收藏题练习</p></div>
                    </div>
                    <!-- 今日热门题目 -->
                     <div class="d5 f">
                        <div class="d6 f"><rankingq></rankingq></div>
                        <div class="d6 f"><rankingp></rankingp></div>
                     </div>
                     <div class="d7">
                         <el-card class="box-card c6" id="main3">
                         </el-card>
                     </div>
                 </div>
            </el-main>
        </el-container>
    </div>

    <script>
        let app = new Vue({
            el: '#app',
            data: {
              typenum: 0,
              images: [
                'image/1.jpg',
                'image/2.png'
              ],
              weekordernum:[],
                uid: null
            },
            created() {

            },
            watch: {
                uid(newVal, oldVal) {
                    if (newVal !== oldVal) {
                        this.getweekordernum();
                    }
                }
            },
            methods: {
                //组件自定义方法
                user(info) {
                    this.uid = info.id;
                },
                type(num){
                  this.typenum = num;
                },
                //查询当周的营业额
                getweekordernum(){
                    axios.post("doquestion/getweekordernum?id=" + this.uid).then(res=>{
                        if(res.data.code === 1){
                            this.weekordernum = res.data.data;
                        }
                    });
                },
            },
            computed: {
                line(){
                    return {
                        title: {
                            text: '近7日刷题量',  // 标题文本
                            left: 'center'        // 标题位置，这里设置为居中
                        },
                        xAxis: {
                            type: 'category',
                            data: [this.weekordernum[0]?.date, this.weekordernum[1]?.date, this.weekordernum[2]?.date, this.weekordernum[3]?.date, this.weekordernum[4]?.date, this.weekordernum[5]?.date, this.weekordernum[6]?.date]
                        },
                        yAxis: {
                            type: 'value'
                        },
                        series: [
                            {
                                itemStyle : { normal: {label : {show: true}}},   //重点是这句加上了后可以显示数字。不然不显示
                                data: [this.weekordernum[0]?.a, this.weekordernum[1]?.a, this.weekordernum[2]?.a, this.weekordernum[3]?.a, this.weekordernum[4]?.a, this.weekordernum[5]?.a, this.weekordernum[6]?.a],
                                type: 'line',
                                smooth: true
                            }
                        ]
                    };
                }
            },
            mounted(){
                // 延迟1秒后初始化图表配置
                setTimeout(() => {
                    // 第三个图表的初始化
                    var chartDom3 = document.getElementById('main3');
                    var myChart3 = echarts.init(chartDom3);
                    myChart3.setOption(this.line); // 注意这里使用 myChart2 而不是 myChart1

                    // 第三个图表的 $watch
                    this.$watch('line', (newOptions) => {
                        myChart3.setOption(newOptions);
                    }, { deep: true });
                }, 500); // 延迟1000毫秒（即1秒）
            }
        });
    </script>
    
</body>
</html>